home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00081_Script_Movimento ondular < prev    next >
Text File  |  1999-03-19  |  3KB  |  99 lines

  1. property spr, iniX, iniY
  2. property anima, marca
  3. property periodoX, deslocamentoX
  4. property periodoY, deslocamentoY
  5. property ampX, ampY
  6. property metodo
  7. property pulo
  8. property memoria, limitado
  9.  
  10. on getBehaviorDescription
  11.   return "Movimento senoidal"
  12. end
  13.  
  14. on getPropertyDescriptionList
  15.   set p_list = [ ¼
  16.     #periodoX: [ #comment: "Periodo do movimento X",¼
  17.                       #format: #integer,¼
  18.                      #default: 600 ],¼
  19.     #deslocamentoX: [ #comment: "Deslocamento do movimento X",¼
  20.                       #format: #integer,¼
  21.                      #default: 0 ],¼
  22.      #ampX: [ #comment: "Amplitude maxima do movimento X",¼
  23.                       #format: #integer,¼
  24.                      #default: 30 ],¼
  25.     #periodoY: [ #comment: "Periodo do movimento Y",¼
  26.                       #format: #integer,¼
  27.                      #default: 600 ],¼
  28.     #deslocamentoY: [ #comment: "Deslocamento do movimento Y",¼
  29.                       #format: #integer,¼
  30.                      #default: 0 ],¼
  31.     #ampY: [ #comment: "Amplitude maxima do movimento Y",¼
  32.                       #format: #integer,¼
  33.                      #default: 30 ],¼
  34.     #metodo: [ #comment: "Extras",¼
  35.                       #format: #integer,¼
  36.                      #default: 0 ],¼
  37.     #memoria: [ #comment: "Limite minimo de memoria para movimento",¼
  38.                       #format: #integer,¼
  39.                      #default: 0 ]¼
  40.   ]
  41.   return p_list
  42. end
  43.  
  44. on beginSprite me
  45.   set spr = the spriteNum of me
  46.   set iniX = the locH of sprite spr
  47.   set iniY = the locV of sprite spr
  48.   set anima = 0
  49.   set pulo = random(periodoX)
  50.   
  51.   global myMemSize  
  52.   if myMemSize < memoria * 1024 * 1024 then
  53.     set limitado = true
  54.   else
  55.     set limitado = false
  56.   end if
  57.   
  58. end
  59.  
  60. on idleSprite me
  61.   if limitado then return
  62.   
  63.   if anima = 0 then
  64.     set anima = the timer
  65.   else
  66.     global gMustUpdate
  67.     set tmp = the timer - anima
  68.     if metodo = 1 then
  69.       if tmp > pulo then
  70.         set anima = anima - random(periodoX)
  71.         set tmp = the timer - anima
  72.         set pulo = 0
  73.       end if
  74.       if tmp > periodoX and tmp > pulo then 
  75.         set pulo = random(periodoX)
  76.         set anima = the timer + periodoX
  77.       end if
  78.     end if
  79.     if ampX <> 0 then
  80.       set tmpX = (tmp + deslocamentoX) mod periodoX
  81.       set tmpX = float(tmpX) / periodoX * 2.0 * pi
  82.       set x = iniX + Integer(sin(tmpX) * ampX)
  83.       if the locH of sprite spr <> x then
  84.         set the locH of sprite spr to x
  85.         set gMustUpdate to true
  86.       end if
  87.     end if
  88.     if ampY <> 0 then
  89.       set tmpY = (tmp + deslocamentoY) mod periodoY
  90.       set tmpY = float(tmpY) / periodoY * 2 * pi
  91.       set y = iniY + Integer(sin(tmpY) * ampY)
  92.       if the locV of sprite spr <> y then
  93.         set the locV of sprite spr to y
  94.         set gMustUpdate to true
  95.       end if
  96.     end if
  97.   end if
  98. end
  99.